<template>
  <div>
    <div class="home">
      <!--头部文字 -->
      <div class="homeContent">
        <div class="homeLeft">
          <img src="../assets/logo.png" alt="">
          <div class="title">
            <h3>铁岭市红十字会</h3>
            <h5>TIE LING RED CROSS</h5>
          </div>
        </div>
        <h1 style="color:#fff;">
          人道 博爱 奉献
        </h1>
      </div>
      <!-- 搜索 -->
      <div class="search">
        <el-input v-model="params" style="width:180px; height:40px" placeholder="请输入关键字" clear
          @keyup.enter="search()" />
        <el-button color="#d9001b" type="primary" style="margin-left: 10px; height:40px; width:90px"
          @click="search()">搜索</el-button>
      </div>
    </div>
    <!-- 导航栏 -->
    <nav>
      <ul>
        <li v-for="(item, i ) in navList" :key="i" :class="tetleName == item.title ? 'active' : ''"
          @click="changTitle(item.title)">
          <router-link :to=item.path>
            {{ item.title }}
          </router-link>
        </li>
      </ul>
    </nav>
  </div>

</template>

<script setup name='HeadNav'>
import { ref, onMounted } from 'vue'
import { useRouter, useRoute } from 'vue-router';
import '../common/font/font.css'
const navList = ref([])
const params = ref('')
const tetleName = ref('首页')
const router = useRouter()
const route = useRoute()
const changTitle = (val) => {
  tetleName.value = val
}
const search = () => {
  if (route.meta.name != '搜索列表') {
    const routerData = router.resolve({ path: "/SearchList", query: { val: params.value } })
    window.open(routerData.href, '_blank')
    params.value = ''
  } else if (route.meta.name == '搜索列表') {
    router.push({ path: "/SearchList", query: { val: params.value } })
  }

}
onMounted(() => {
  router.options.routes.map((item) => {
    if (item.meta.isShow != false) {
      navList.value.push({ path: item.path, title: item.meta.name })
    }
  })
})

</script>

<style lang="scss" scoped>
.home {
  height: 200px;
  width: 100%;
  background-image: url(../assets/backdrop.jpg);
  background-repeat: no-repeat;
  background-size: 100% 200px;
  position: relative;

  .homeContent {
    display: flex;
    justify-content: space-between;
    height: 100%;
    width: 80%;
    align-items: center;

    .homeLeft {
      display: flex;
      margin-left: 10%;
      align-items: center;

      img {
        width: 120px;
        height: 100px;
      }

      .title {
        color: #f0f0f0;
        display: flex;
        flex-direction: column;

        h3 {
          margin: 0;
          font-size: 36px;
        }

        h5 {
          margin: 0;
          font-size: 24px;
        }
      }
    }

    h1 {
      margin: 0;
      font-size: 80px;
      font-weight: 400;
      font-family: PingFang;
    }
  }

  .search {
    position: absolute;
    bottom: 10px;
    right: 25px;
    z-index: 10000;

    :deep .el-input__wrapper {
      background-color: rgba(255, 255, 255, 0.1);
    }

    :deep .el-input__inner {
      color: #f0f0f0;
    }

    :deep input::-webkit-input-placeholder {
      -webkit-text-fill-color: #d7d7d7;
    }
  }
}

nav {
  height: 60px;
  width: 100%;
  background-color: #dd0f34;

  ul {
    width: 85%;
    margin: auto;
    list-style: none;
    display: flex;
    line-height: 60px;
    justify-content: space-around;
    align-items: center;
    padding: 0;
    text-align: center;

    li {
      width: 160px;
      height: 60px;
    }

    a {
      color: #fff;
      text-decoration: none;
      padding-bottom: 10px;
      font-size: 20px;
      font-weight: 400;
    }
  }
}

ul li:hover {
  background-color: rgb(0, 0, 0, 0.2);
}
</style>